package com.example.jobs;

import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.Properties;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class TestJobs {
	public final static long ONE_Minute =  60 * 1000;
	static String name=null;
	static{
		Properties props = new Properties();
		InputStream in = null;
		try {
			in = TestJobs.class.getClassLoader().getResourceAsStream("myConfig.properties");
			props.load(in);
			name=(String) props.get("name");
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if(in!=null){
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
	
    @Scheduled(fixedDelay=ONE_Minute*3)
    public void fixedDelayJob(){
        System.out.println(new Date()+" >>fixedDelay执行...."+name+"真的是个250，鉴定完毕！");
    }

    @Scheduled(fixedRate=ONE_Minute)
    public void fixedRateJob(){
        System.out.println(new Date()+" >>fixedRate执行...."+name+"好像是个250！");
    }

    @Scheduled(cron="0 15 3 * * ?")
    public void cronJob(){
        System.out.println(new Date()+" >>cron执行....");
    }
}
